import { getAppData, setGlobalData } from '@utils/tools'
import { AtTabs, AtTabsPane, AtList } from "taro-ui"
import { BaseComponent } from '@common/components/base-component';
import { BasePage } from '@common/components/base-page'
import NavigationBar from '@components/navBar'
import PickerAddress from '@components/picker-address';
import IQRequest from '@common/iq-request/request'
import Jump from '@utils/jump'
import AppRoute from '@utils/route/index'

import { View, Image, Text, Input, Textarea, Radio, Button, ScrollView } from '@tarojs/components'
import style from './index.module.scss'

interface CProps {
    selectMedia: boolean,
    close: Function,
}
interface CState {
    clickedSelectPanel: boolean,
    selectedPlat: string,
    isChecked: boolean,
    provinceList: any
}
export default class addAddress extends BaseComponent<CProps, CState> {
    constructor(props) {
        super(props);
        this.state = {
            clickedSelectPanel: false,
            selectedPlat: '',
            isChecked: false,
            provinceList: []

        }
    }
    componentDidShow() {
    }
    closeMediaChange = (plat) => {
        console.log(plat, '选择的地区')
        this.setState({
            // selectedPlat: plat.title,
            clickedSelectPanel: false
        })
    }
    handleAddress = async (code) => {
        this.setState({
            clickedSelectPanel: true
        })
        // IQRequest.handleOrigin(0)
    }

    render() {
        const { isChecked, provinceList } = this.state
        const handleRadio = () => {
            this.setState({
                isChecked: !isChecked
            })
        }
        return (
            <ScrollView style={{ height: '100vh' }} enhanced={true} scrollY={true}>
                <NavigationBar backPageShow={true} titleColor="black" barBackgroundColor='white' title="新建收货地址"></NavigationBar>
                <View className={`${style.addressList} ${style.aBase}`}>
                    <View className={style.formItem}>
                        <Text className={style.person}>收件人</Text>
                        <Input type='text' placeholder='收件人姓名' placeholderClass={style.place} focus />
                    </View>
                    <View className={style.formItem}>
                        <Text className={style.person}>手机号</Text>
                        <Input type='text' placeholder='手机号' placeholderClass={style.place} focus />
                    </View>
                    <View className={style.formItem}>
                        <Text className={style.person}>所在地区</Text>
                        <Input onClick={this.handleAddress} type='text' placeholder='省市区县、乡镇等' placeholderClass={style.place} focus />
                    </View>
                    <View className={style.formItem}>
                        <Text className={style.person}>详细地址</Text>
                        <Textarea placeholder='街道、楼牌号等' placeholderClass={style.place} focus />
                    </View>
                    <View className={`${style.selectRadio} ${style.vertical}`}>
                        <Radio onClick={handleRadio} checked={isChecked} style={{ transform: 'scale(0.7)' }} value='选中' color='#415FFF'></Radio>
                        <Text>默认收货地址</Text>
                    </View>
                </View>
                <View className={style.btnSave}>
                    <Button onClick={() => { }} className={style.aBtn}>保存</Button>
                </View>
                <PickerAddress  level={3} selectMedia={this.state.clickedSelectPanel} title="选择地址" close={this.closeMediaChange} />
            </ScrollView>
        )
    }
}
